package com.zq.zqplayer.mvp.main.ui

import androidx.activity.viewModels
import androidx.lifecycle.ViewModel
import com.zq.zqplayer.bean.RoomInfoBean
import com.zq.zqplayer.http.BaseObserver
import com.zq.zqplayer.http.request.LiveRequest
import com.zq.zqplayer.http.response.BaseResponse
import com.zq.zqplayer.http.service.VideoService
import dagger.hilt.android.lifecycle.HiltViewModel
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import javax.inject.Inject

@HiltViewModel
class RecommendViewModel : ViewModel {

    @Inject
    constructor() : super(){
    }

    @Inject
    lateinit var videoService: VideoService

    fun getLiveList() {
        val request = LiveRequest()
        request.offset = "0"
        request.limit = "20"

        videoService.getLiveList(HashMap(), request)
            .subscribeOn(Schedulers.io())
            .doOnSubscribe {
//                mView.showLoading()
            }
            .subscribeOn(AndroidSchedulers.mainThread())//控制doOnSubscribe 所在线程
            .observeOn(AndroidSchedulers.mainThread())
            .doFinally {
//                mView.hideLoading()
            }
            .subscribe(object : BaseObserver<BaseResponse<ArrayList<RoomInfoBean>>>() {
                override fun onSuccessful(t: BaseResponse<ArrayList<RoomInfoBean>>?) {
                    println("")
                }

                override fun onFailed(msg: String?) {
                }
            })
    }
}